Skip to main content

How to modify the texture of a ModelRenderer by script using Java

In your Java class, do the following:

public class YourClass extends Component {

// creates a new Texture
public Texture texture; // select in properties

// creates a new ModelRenderer, @AutoWired selects the component from this object
@AutoWired
private ModelRenderer modelRenderer;

@Override
public void start() {

// changing the texture of the object's ModelRenderer
modelRenderer.getMaterial().setTexture("albedo", texture);
}

@Override
public void repeat() {

}
}